package controllers

import (
	"github.com/astaxie/beego"
)

type ErrorController struct {
	beego.Controller
}

const (
	// 搜索相关
	SearchReturnNull = 501
	InvalidSearch    = 502

	ContentIsNull = 511
	IllegalParam  = 512

	PageOutOfRange = 521

	// 未完善信息
	IncompleteInformation = 531
	WxNotBound            = 532

	AlreadyAccept = 541

	// 用户名密码相关
	UsernameAlreadyExist = 551
	PasswordTooShort     = 552
	PasswordAllDigit     = 553
	IllegalPassword      = 554
	ImportFailed         = 555
	UserNotExist         = 556

	// service相关
	LoginFailed  = 561
	UserNotLogin = 562

	// live相关
	LiveCreate   = 571
	LiveNotFound = 572

	// resume相关
	SocialPracticeNotEnough = 581
	UserResumeNotExist      = 582

	SystemFailed = 599

	// 聊天室相关
	CreateChatRoomFailed = 601
	ConnectionFailed     = 602
	JoinRoomFailed       = 603

	// company job 相关
	JobNotExist = 611
)

func (e *ErrorController) RetData(resp map[string]interface{}) {
	resp["code"] = 400
	resp["data"] = nil
	e.Data["json"] = &resp
	e.ServeJSON()
}

func (e *ErrorController) ErrorUserNotLogin() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = UserNotLogin
	resp["msg"] = "用户未登录!!!"
}

func (e *ErrorController) ErrorUserNotExist() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = UserNotExist
	resp["msg"] = "用户不存在!!!"
}

func (e *ErrorController) ErrorPasswordNotSame() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Password Not Same"
}

func (e *ErrorController) ErrorParamIsEmpty() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Param Is Empty"
}

func (e *ErrorController) ErrorGetDataFail() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Get Data Fail"
}

func (e *ErrorController) ErrorAddDataFail() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Add Data Fail"
}

func (e *ErrorController) ErrorUpdateDataFail() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Update Data Fail"
}

func (e *ErrorController) ErrorDeleteDataFail() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Delete Data Fail"
}

func (e *ErrorController) ErrorJsonToObjectFail() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Json To Object Fail"
}

func (e *ErrorController) ErrorCompanyNotLogin() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Company Not Login"
}

func (e *ErrorController) ErrorReadFileFail() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Read File Fail"
}

func (e *ErrorController) ErrorDataAlreadyExist() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Data Already Exist"
}

func (e *ErrorController) ErrorSendSMSFail() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Send SMS Fail"
}

func (e *ErrorController) ErrorVerifyCode() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Verify Code is Error"
}

func (e *ErrorController) ErrorUserIsExist() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "User is Exist"
}

func (e *ErrorController) ErrorReadParam() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Read Param Error"
}

func (e *ErrorController) ErrorSearchReturnNull() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["errCode"] = SearchReturnNull
	resp["msg"] = "搜索内容为空"
}

func (e *ErrorController) ErrorInvalidSearch() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["errCode"] = InvalidSearch
	resp["msg"] = "搜索内容不规范"
}

func (e *ErrorController) ErrorContentIsNull() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["errCode"] = ContentIsNull
	resp["msg"] = "内容为空"
}

func (e *ErrorController) ErrorPageOutOfRange() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["errCode"] = PageOutOfRange
	resp["msg"] = "页数超过限制"
}

func (e *ErrorController) ErrorContentAlreadyExist() {
	resp := make(map[string]interface{})
	defer e.RetData(resp)

	resp["msg"] = "Content Already Exist"
}

func (e *ErrorController) ErrorIncompleteInformation() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = IncompleteInformation
	resp["msg"] = "请完善用户信息"
}

func (e *ErrorController) ErrorAlreadyAccept() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = AlreadyAccept
	resp["msg"] = "您已同意一个公司，不可再同意"
}

func (e *ErrorController) ErrorIllegalParam() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = IllegalParam
	resp["msg"] = "参数错误!!!"
}

func (e *ErrorController) ErrorUsernameAlreadyExist() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = UsernameAlreadyExist
	resp["msg"] = "用户名已存在, 请换个用户名重试!!!"
}

func (e *ErrorController) ErrorPasswordAllDigit() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = PasswordAllDigit
	resp["msg"] = "密码不可全为数字!!!"
}

func (e *ErrorController) ErrorPasswordTooShort() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = PasswordTooShort
	resp["msg"] = "密码不可少于6位!!!"
}

func (e *ErrorController) ErrorLoginFailed() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = LoginFailed
	resp["msg"] = "登录失败, 用户名或密码错误"
}

func (e *ErrorController) ErrorSystemFailed() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = SystemFailed
	resp["msg"] = "系统错误"
}

func (e *ErrorController) ErrorLiveCreate() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = LiveCreate
	resp["msg"] = "直播创建失败"
}

func (e *ErrorController) ErrorLiveNotFound() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = LiveNotFound
	resp["msg"] = "未找到该公司的直播!!!"
}

func (e *ErrorController) ErrorImportFailed() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = ImportFailed
	resp["msg"] = "导入失败"
}

func (e *ErrorController) ErrorSocialPracticeNotEnough() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = SocialPracticeNotEnough
	resp["msg"] = "请完善社会实践"
}

func (e *ErrorController) ErrorWxNotBound() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = WxNotBound
	resp["msg"] = "尚未绑定微信"
}

func (e *ErrorController) ErrorCreateChatRoomFailed() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = CreateChatRoomFailed
	resp["msg"] = "创建聊天室失败!!!"
}

func (e *ErrorController) ErrorUserResumeNotExist() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = UserResumeNotExist
	resp["msg"] = "用户还未拥有简历!!!"
}

func (e *ErrorController) ErrorJobNotExist() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = JobNotExist
	resp["msg"] = "找不到该岗位!!!"
}

func (e *ErrorController) ErrorConnectionFailed() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = ConnectionFailed
	resp["msg"] = "聊天室连接失败!!!"
}

func (e *ErrorController) ErrorJoinRoomFailed() {
	resp := make(map[string]interface{})

	defer e.RetData(resp)

	resp["errCode"] = JoinRoomFailed
	resp["msg"] = "加入聊天室失败!!!"
}
